<?php
ini_set('zend.ze1_compatibility_mode',0);

header('Content-Type:application/xml');

if(isset($_POST['design']))
{   $xml = new DOMDocument($_POST['design'].".xsl");
    $xml->load($_POST['design'].".xsl");
    $root = $xml->documentElement;
    $root->removeChild($root->childNodes->item(3));
    $A = $xml->getElementsByTagNameNS('http://www.w3.org/1999/XSL/Transform','param');
    $A->item(0)->nodeValue = $_POST['skin'];
    $A->item(1)->nodeValue = $_POST['id'];
    $A->item(4)->nodeValue = $_POST['skin'];
    $A->item(5)->nodeValue = $_POST['id'];
    $resxml = preg_replace("/<!--.*-->/ims","",$xml->saveXML());
}
else
{   $sxe = simplexml_load_file($_POST['xmlfile']);
    $res='';
    foreach($sxe->xpath(stripslashes($_POST['xpath'])) as $v)
    {   $res .= $v->asXML()."\r\n";
    }
    $resxml = simplexml_load_string("<fwc:options xmlns:fwc='http://alx.vingrad.ru/fwc'>".$res."</fwc:options>");
    $resxml = $resxml->asXML();
}

echo $resxml;

?>
